<?php
/**
 * 直播api公共控制器 V2
 * @author Wayne qiaobin@zhiyicx.com
 */
 
namespace app\common\controller;
use app\common\controller\Api;

class ZhiboV2 extends Api
{
	/**
     * @name 获得HUB的方法
     * @access protected
     * @return object HUB 类
     */
    protected function getHub(){
        // Instantiate an Hub object
        $stream_service = model('admin/Config')->getConfigValue(['type'=>'stream','key'=>'stream_service']);
        // $credentials = new \vendor\zhibo\Qiniu\Credential($stream_service['qiniu_accessKey'],$stream_service['qiniu_secretKey']); #=> Credentials Object
        // //get new hub
        // //$config_hub = end(C('qiniu_hub'));
        // $config_hub = $stream_service['hub_name'];
        // return new \vendor\zhibo\Pili\Hub($credentials, $config_hub); # => Hub Object

        // v2
        $mac 			= new \Qiniu\Pili\Mac($stream_service['qiniu_accessKey'],$stream_service['qiniu_secretKey']);
        $client 		= new \Qiniu\Pili\Client($mac);
        $hub 			= $client->hub($stream_service['hub_name']);

        return $hub;
    }
}
